package forum.communication;

import forum.server.controller.ForumFacadeInt;
import forum.server.exceptions.DatabaseException;

/**
 * @author Tamir 
 *
 */
public class LogoffMessage extends ClientMessage {

	private static final long serialVersionUID = -5965616226069995574L;
	private boolean exitStatus;
	
	public LogoffMessage(boolean exit){
		this.exitStatus = exit;
	}
	/* (non-Javadoc)
	 * @see forum.tcpcommunicationlayer.ClientMessage#doOperation(forum.server.domainlayer.ForumFacade)
	 */
	@Override
	public ServerResponse doOperation(ForumFacadeInt forum){
	try{
		forum.logoff(exitStatus);
		return new ServerResponse("Bye Bye.",true);
	} catch (DatabaseException e) {
		return new ServerResponse("The server is currently down for maintanance.\nPlease try again later.",false);
	}
	
	}

}
